package cn.hxth.cloud.provider.controller;

import cn.hxth.cloud.api.domain.*;
import cn.hxth.cloud.provider.service.InventoryService;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

@RestController
@RequestMapping("/inventory/")
public class InventoryController {
    @Resource
    private InventoryService inventoryService ;
    @PutMapping("updateProductInventoryForOrder")
    public  Boolean updateProductInventoryForOrder(@RequestBody OrderInfo orderInfo){
        return  inventoryService.updateProductInventoryForOrder(orderInfo) ;

    }
    @PutMapping("updateSteelsInventoryForOrder")
    public  Boolean updateSteelsInventoryForOrder(@RequestBody ProductionOrder[] productionOrders){
      return   inventoryService.updateSteelsInventoryForOrder(Arrays.asList(productionOrders)) ;
    }
    @PutMapping("updateSteelsInputInventory")
    public  Boolean updateSteelsInputInventory(@RequestBody SteelsInputOrder steelsInputOrder){
        return  this.inventoryService.updateSteelsInputInventory(steelsInputOrder) ;
    }
    @PutMapping("updateSteelsOutputInventory")
    public Boolean updateSteelsOutputInventory(@RequestBody  SteelsOutputOrder steelsOutputOrder){
        return  this.inventoryService.updateSteelsOutputInventory(steelsOutputOrder) ;
    }
    @PutMapping("updateProductOutputInventory")
    public Boolean updateProductOutputInventory(@RequestBody ProductOutputOrder productOutputOrder){
        return this.inventoryService.updateProductOutputInventory(productOutputOrder) ;
    }
    @PutMapping("updateProductInputInventory")
    public Boolean updateProductInputInventory(@RequestBody ProductInputOrder productInputOrder){
        return this.inventoryService.updateProductInputInventory(productInputOrder);
    }


}
